package com.minimalist.lindi.mapper;

import com.minimalist.common.entity.lindi.po.LindiSubsidyApplicationPayNotice;
import com.minimalist.common.entity.lindi.vo.subsidyapplicationpaynotice.LindiSubsidyApplicationPayNoticeQueryVO;
import com.mybatisflex.core.BaseMapper;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;

import java.util.List;

/**
 * 林地指标交易平台_补贴申请支付通知表 映射层。
 *
 * @author 11987
 * @since 2025-06-11
 */
public interface LindiSubsidyApplicationPayNoticeMapper extends BaseMapper<LindiSubsidyApplicationPayNotice>{

    /**
     * 根据补贴申请支付通知ID查询补贴申请支付通知
     *
     * @param subsidyApplicationPayNoticeId 补贴申请支付通知ID
     * @return 补贴申请支付通知
     */
    default LindiSubsidyApplicationPayNotice selectSubsidyApplicationPayNoticeBySubsidyApplicationPayNoticeId(Long subsidyApplicationPayNoticeId){
        return selectOneByQuery(QueryWrapper.create().eq(
                LindiSubsidyApplicationPayNotice::getSubsidyApplicationPayNoticeId
                , subsidyApplicationPayNoticeId));
    }

    /**
     * 根据ID查询补贴申请支付通知
     *
     * @param subsidyApplicationPayNoticeId 补贴申请支付通知ID
     * @return 补贴申请支付通知
     */
    default LindiSubsidyApplicationPayNotice getSubsidyApplicationPayNoticeById(Long subsidyApplicationPayNoticeId){
        return selectOneByQuery(QueryWrapper.create()
                .eq(LindiSubsidyApplicationPayNotice::getSubsidyApplicationPayNoticeId
                        , subsidyApplicationPayNoticeId));
    }

    /**
     * 分页查询补贴申请支付通知列表
     *
     * @param queryVO 查询条件
     * @return 分页结果
     */
    default Page<LindiSubsidyApplicationPayNotice> selectPageSubsidyApplicationPayNoticeList(LindiSubsidyApplicationPayNoticeQueryVO queryVO){
        return paginate(queryVO.getPageNum(), queryVO.getPageSize(),
                QueryWrapper.create()
                        .eq(LindiSubsidyApplicationPayNotice::getSubsidyApplicationId, queryVO.getSubsidyApplicationId())
                        .eq(LindiSubsidyApplicationPayNotice::getSubsidyApplicationPayNoticeId, queryVO.getSubsidyApplicationPayNoticeId())
                        .ge(LindiSubsidyApplicationPayNotice::getNoticeDate, queryVO.getStartDate())
                        .le(LindiSubsidyApplicationPayNotice::getNoticeDate, queryVO.getEndDate())
                        .like(LindiSubsidyApplicationPayNotice::getPayTitle, queryVO.getPayTitle())
                        .like(LindiSubsidyApplicationPayNotice::getPayExplain, queryVO.getPayExplain())
                        .orderBy(LindiSubsidyApplicationPayNotice::getCreateTime, false));
    }

    /**
     * 根据需支付金额查询支付通知列表
     *
     * @param needMoney 需支付金额
     * @return 支付通知列表
     */
    default List<LindiSubsidyApplicationPayNotice> selectPayNoticeListByNeedMoney(String needMoney){
        return selectListByQuery(QueryWrapper.create()
                .orderBy(LindiSubsidyApplicationPayNotice::getCreateTime, false));
    }

    /**
     * 根据通知时间范围查询支付通知列表
     *
     * @param startDate 开始时间
     * @param endDate   结束时间
     * @return 支付通知列表
     */
    default List<LindiSubsidyApplicationPayNotice> selectPayNoticeListByDateRange(java.sql.Timestamp startDate, java.sql.Timestamp endDate){
        return selectListByQuery(QueryWrapper.create()
                .ge(LindiSubsidyApplicationPayNotice::getNoticeDate, startDate)
                .le(LindiSubsidyApplicationPayNotice::getNoticeDate, endDate)
                .orderBy(LindiSubsidyApplicationPayNotice::getCreateTime, false));
    }

    /**
     * 根据补贴申请ID查询支付通知列表
     *
     * @param subsidyApplicationId 补贴申请ID
     * @return 支付通知列表
     */
    default List<LindiSubsidyApplicationPayNotice> selectPayNoticeListBySubsidyApplicationId(Long subsidyApplicationId){
        return selectListByQuery(QueryWrapper.create()
                .eq(LindiSubsidyApplicationPayNotice::getSubsidyApplicationId
                        , subsidyApplicationId)
                .orderBy(LindiSubsidyApplicationPayNotice::getCreateTime, false));
    }

    /**
     * 根据支付通知ID删除支付通知
     *
     * @param subsidyApplicationPayNoticeId 支付通知ID
     * @return 删除结果
     */
    default int deleteSubsidyApplicationPayNoticeBySubsidyApplicationPayNoticeId(
            Long subsidyApplicationPayNoticeId){
        return deleteByQuery(QueryWrapper.create()
                .eq(LindiSubsidyApplicationPayNotice::getSubsidyApplicationPayNoticeId
                        , subsidyApplicationPayNoticeId));
    }
}
